<?php

namespace App\Admin\Requests;

use Illuminate\Support\Facades\Auth;
use App\Rules\Admin\IsOldPasswordVaildRule;

class ProfilePasswordUpdateRequest extends Request
{
    public function rules()
    {
        return [
            'old_password' => ['bail', 'required', new IsOldPasswordVaildRule(auth('admin')->id())],
            'password'     => 'bail|required|between:6,20|different:old_password|confirmed',
        ];
    }

    public function messages()
    {
        return [
            'old_password.required' => '舊密碼不能為空',
            'password.required'     => '新密碼不能為空',
            'password.between'      => '新密碼必須在6至20位之間',
            'password.confirmed'    => '新密碼和確認密碼不匹配',
            'password.different'    => '新舊密碼不能相同',
        ];
    }
}
